/**
 * 自定义函数
 * */


//列表
function getList(){
    var uinfo = getAdminInfo();
    if (!uinfo) { return }
    var pageStart = getParamByUrl('start');
    pageStart = pageStart ? pageStart : pages.start;
    var formData = {
        uid: uinfo.uid,
        //role_id: uinfo.role_id,
        // depart_id: uinfo.depart_id,
        start: pageStart, limit: pages.limit,
    };
    $.ajax({
        type: apiMethod,
        url: apiDomain + 'tongji/huan',
        data: formData,
        success: function (res) {
            console.log(res);
            var h = '', tbody = $('tbody');
            if (res.code < 0) {
                h = '<tr class="text-c">';
                h += '<td colspan="10">没有记录</td>';
                h += '</tr>';
                tbody.html(h);
                return
            }
            tbody.html(getHtml(res.data));
            $('#pageTotal').html(res.total);
            pages.start = pageStart;
            pages.total = res.total;
            pageHtml(pages);
        },
        error: function () {
            console.log('网络错误');
        }
    });
}
//列表字符串
function getHtml(d){
    var h = '', i;
    h += '';
    for (i = 0; i < d.length; i ++) {
        h += '<tr class="text-c">';
        // h += '<td>' + d[i].id + '</td>';
        h += '<td>' + d[i].depart_name + '</td>';
        h += '<td>' + d[i].item_name + '</td>';
        h += '<td>';
        whList = d[i].whList;
        if (whList.length > 0) {
            for (ii = 0; ii < whList.length; ii ++) {
                h += '<div>';
                h += whList[ii].wh_name + '，' + whList[ii].delay_str;
                h += '<div>';
            }
        } else {
            h += '-';
        }
        h += '</td>';
        h += '<td>' + d[i].delay_str + '</td>';
        h += '<td>' + d[i].tongbi + '</td>';
        h += '<td>' + d[i].huanbi + '</td>';
        h += '</tr>';
    }
    return h;
}